package com.other.thread.base;

public class Stage extends Thread {
	@Override
	public void run() {
		System.out.println("舞台拉开序幕");
		
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
		System.out.println("---------开战----------");
		ArmyRunnable army1 = new ArmyRunnable();
		ArmyRunnable army2 = new ArmyRunnable();
		
		Thread t1 = new Thread(army1, "隋军");
		Thread t2 = new Thread(army2, "农民军");
		
		t1.start();
		t2.start();
		
		try {
			Thread.sleep(50);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("英雄人物即将出场--------------------------");
		army1.keepRunning = false;
		army2.keepRunning = false;
		
		try {
			Thread.sleep(2000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
		Thread keyPerson = new KeyPersonThread();
		keyPerson.setName("程咬金");
		keyPerson.start();
		
		try {
			//所有线程等待当前线程完成后执行
			keyPerson.join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
		System.out.println("谢谢观看-------------------");
	}
	
	public static void main(String[] args) {
		Thread stage = new Stage();
		stage.start();
	}
}



